//
//  CLScanViewController.m
//  JG
//
//  Created by 程龙 on 2023/8/10.
//

#import "CLScanViewController.h"
#import "CLScanView.h"
@interface CLScanViewController ()

@end

@implementation CLScanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    __weak typeof(self) weakSelf = self;
    CLScanView *qrcodeView = [[CLScanView alloc] initWithFrame:self.view.bounds];
    qrcodeView.backQRCodeURL = ^(NSString *stringValue) {
//        [weakSelf alertViewTitle:@"扫描成功" Message:stringValue];

        weakSelf.block(stringValue);
        [self.navigationController popViewControllerAnimated:YES];

    };
    qrcodeView.backfailure = ^{
        [weakSelf alertViewTitle:@"扫描失败" Message:@"扫描失败"];
    };
    [self.view addSubview:qrcodeView];
    

}

- (void)alertViewTitle:(NSString *)title Message:(NSString *)message
{
    __weak typeof(self) weakSelf = self;
    UIAlertController *alertV = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    [alertV addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        //[weakSelf.navigationController popViewControllerAnimated:YES];
    }]];
    [self presentViewController:alertV animated:YES completion:nil];
}

@end
